﻿#region License
// Copyright (c) 2009-2010 Topian System - http://www.topian.net
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#endregion

using System;

namespace System.Diagnostics.IntelliTrace
{
    /// <summary>
    /// Declares a &lt;Category/&gt; in the collectionPlan.xml
    /// </summary>
    [AttributeUsage(AttributeTargets.Assembly)]
    public class CategoryAttribute : Attribute
    {
        public string Id { get; private set; }
        public string Description { get; private set; }

        /// <summary>
        /// Declares a &lt;Category/&gt; in the collectionPlan.xml
        /// </summary>
        public CategoryAttribute(string id, string description)
        {
            this.Id = id;
            this.Description = description;
        }
    }

    /// <summary>
    /// Declares a &lt;ModuleSpecification/&gt; in the collectionPlan.xml
    /// </summary>
    [AttributeUsage(AttributeTargets.Assembly)]
    public class ModuleSpecificationAttribute : Attribute
    {
        public string Id { get; private set; }
        public int MinVersion { get; set; }
        public int MaxVersion { get; set; }

        /// <summary>
        /// Declares a &lt;ModuleSpecification/&gt; in the collectionPlan.xml
        /// </summary>
        public ModuleSpecificationAttribute(string id)
        {
            this.Id = id;
        }
    }

    /// <summary>
    /// Declares a &lt;DiagnosticEvent/&gt; in the collectionPlan.xml
    /// </summary>
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
    public class DiagnosticEventAttribute : Attribute
    {
        public bool Enabled { get; set; }
        public string ModuleSpecificationId { get; set; }
        public string CategoryId { get; set; }
        public string SettingsName { get; private set; }
        public string SettingsDescription { get; private set; }

        /// <summary>
        /// Declares a &lt;DiagnosticEvent/&gt; in the collectionPlan.xml
        /// </summary>
        /// <param name="settingsName">The &lt;settingsName/&gt; element</param>
        /// <param name="settingsDescription">The &lt;settingsDescription/&gt; element</param>
        public DiagnosticEventAttribute(string settingsName, string settingsDescription)
        {
            this.Enabled = true;
            this.SettingsName = settingsName;
            this.SettingsDescription = settingsDescription;
        }
    }

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
    public class BindingAttribute : Attribute
    {
        public string ModuleSpecificationId { get; set; }
        public string ShortDescription { get; private set; }
        public string LongDescription { get; private set; }
        public Type ProgrammableQueryType { get; private set; }

        public BindingAttribute(string shortDescription)
            : this(shortDescription, shortDescription)
        {
        }

        public BindingAttribute(string shortDescription, string longDescription)
        {
            this.ShortDescription = shortDescription;
            this.LongDescription = longDescription;
        }

        public BindingAttribute(Type programmableQueryType)
        {
            this.ProgrammableQueryType = programmableQueryType;
        }
    }

    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)]
    public class DataQueryAttribute : Attribute
    {
        public int MaxSize { get; set; }
        public string Name { get; set; }
        public Type Type { get; set; }
        public string Query { get; set; }
    }
}